import Vue from 'vue'
import Router from 'vue-router'

const index = () => import('../components/index')
const recommend = () => import('../components/recommend')
const hot = () => import('../components/hot')
const search = () => import('../components/search')
const songlist = () => import('../components/songlist')
const song = () => import('../components/song.vue')

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      // 重定向
      redirect: '/recommend'
    },
    {
      path: '/',
      component: index,
      children:[
        {path: 'recommend', component: recommend},
        {path: 'hot', component: hot},
        {path: 'search', component: search}
      ]
    },
    {
      path: '/recommend', 
      name: 'recommend',
      component: recommend
    },
    // 动态路由：根据id获取歌单详情
    {
      path: '/songlist/:id',
      component: songlist
    },
    // 动态路由：根据id获取歌曲详情 封面 歌词等
    {
      path: '/song/:id',
      component: song
    }
  ]
})
